import { request } from './request';

export function getRoles(params) {
    return request({
        url: `/roles`,
        method: 'GET',
        params
    })
}

export function addRole(data) {
    return request({
        url: `/roles`,
        method: 'POST',
        data
    })
}

export function removeRightById(roleId, rightId) {
    return request({
        url: `roles/${roleId}/rights/${rightId}`,
        method: 'DELETE'
    })
}

export function setRoleRights(roleId, data) {
    return request({
        url: `roles/${roleId}/rights`,
        method: 'POST',
        data
    })
}

export function deleteRoleById(id) {
    return request({
        url: `/roles/${id}`,
        method: 'DELETE'
    })
}

export function getRoleById(id) {
    return request({
        url: `/roles/${id}`,
        method: 'GET'
    })
}

export function editRoleById(id, data) {
    return request({
        url: `/roles/${id}`,
        method: 'PUT',
        data
    })
}